<template>
	<div class="zBox">
		<div class="top">
			<el-form class="xHeight" :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
				<el-form-item label="姓名" prop="name"><el-input v-model="queryParams.name" placeholder="请输入" maxlength="30" /></el-form-item>
				<el-form-item label="时间" prop="time">
					<el-date-picker
						v-model="dateRange"
						type="daterange"
						range-separator="-"
						value-format="YYYY-MM-DD"
						start-placeholder="开始日期"
						end-placeholder="结束日期"
					></el-date-picker>
				</el-form-item>
				<el-form-item>
					<div class="cz" @click="reset">重置</div>
					<div class="cx" @click="getList">查询</div>
				</el-form-item>
			</el-form>
		</div>
		<div class="bottom">
			<el-table class="qjTable" v-loading="loading" :data="tableList" height="600" stripe>
				<el-table-column label="姓名" align="center" prop="createBy" />
				<el-table-column label="类型" align="center" prop="type_mc" />
				<el-table-column label="开始时间" align="center" prop="startTime" />
				<el-table-column label="结束时间" align="center" prop="endTime" />
				<el-table-column label="请假时长" align="center" prop="absenceDuration" />
				<el-table-column label="提交时间" align="center" prop="createTime" />
				<el-table-column label="状态" align="center">
					<template #default="scope">
						<div class="ztbox">
							<div class="dian" :style="{ background: qjzt[scope.row.state].color }"></div>
							<span :style="{ color: qjzt[scope.row.state].color }">{{ qjzt[scope.row.state].lable }}</span>
						</div>
					</template>
				</el-table-column>
				<el-table-column label="操作" align="center">
					<template #default="scope">
						<div class="czan">
							<div class="czBut bjckdj" @click="detail(scope.row.absenceId)">查看</div>
						</div>
					</template>
				</el-table-column>
			</el-table>
			<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
		</div>
	<el-dialog class="qjdialog" v-model="detailDialogVisible" title="抄送我的" top="8vh" width="45%">
		
		<div class="shbj">请假信息</div>
		<table class="mailTable">
			<tr>
				<td class="column ">姓名</td>
				<td class="nrkd">{{ qjDetail.createBy }}</td>
				<td class="column">提交时间</td>
				<td class="nrkd">{{ qjDetail.createTime }}</td>
			</tr>
			<tr>
				<td class="column ">开始时间</td>
				<td class="nrkd">{{ qjDetail.startTime }}</td>
				<td class="column ">结束时间</td>
				<td class="nrkd">{{ qjDetail.endTime }}</td>
			</tr>
			<tr>
				<td class="column ">请假类型</td>
				<td class="nrkd">{{ qjDetail.type }}</td>
				
				<td class="column ">抄送人</td>
				<td class="nrkd">{{ qjDetail.copyNames }}</td>
		
			</tr>
			<tr>
				<td class="column ">请假时长</td>
				<td class="nrkd">{{ qjDetail.absenceDuration }}小时</td>
				<td class="column">调休时长</td>
				<td class="nrkd">{{ qjDetail.sabbaticalHour }}小时</td>
			</tr>
			<tr>
				<td class="column">请假事由</td>
				<td class="nrkd lineHeight" colspan="3">{{ qjDetail.reason || '暂无' }}</td>
			</tr>
			<tr>
				<td class="column">审核进度</td>
				<td class="nrkd lineHeight" colspan="3">
					<p class="jdbox" style="display: flex;" v-for="(item, index) in auditList">
						<span class="spzt"  :class="{ytg:item.status==2,btg:item.status==3,dsh:item.status==1}"></span>
						<span class="xuLine" style="position: absolute;width: 2px;height: 20px;border: 1px dashed #ccc;"></span>
						<span>
							{{
								item.approveUser +
									'\xa0\xa0\xa0' +
									(item.status == 1 ? '待审核' : item.approveTime) +
									'\xa0\xa0\xa0' +
									(item.approveReason ? item.approveReason : '')
							}}
						</span>
					</p>
				</td>
			</tr>
			
			
		</table>	
		<div v-if="qjDetail.state >=4" class="shbj sptop">销假信息</div>
		
		<table v-if="qjDetail.state >=4" class="mailTable">
			<!-- 销假信息 -->
			<tr>
				<td class="column ">销假时间</td>
				<td class="nrkd">{{ xjDetail.reportBackTime }}</td>
				<td class="column ">销假时长</td>
				<td class="nrkd">{{ xjDetail.reportBackDuration }}小时</td>
			</tr>
			<tr>
				<td class="column">备注</td>
				<td class="nrkd lineHeight" colspan="3">{{ xjDetail.reportBackReason || '暂无' }}</td>
			</tr>
		</table>
		
		<table v-if="qjDetail.state == 5 || qjDetail.state == 6" class="mailTable">
			<!-- 销假审核信息 -->
			<tr>
				<td class="column ">审核人</td>
				<td class="nrkd">{{ qjDetail.approveUser }}</td>
				<td class="column ">审核时间</td>
				<td class="nrkd">{{ xjDetail.approveTime }}</td>
			</tr>
			<tr>
				<td class="column">审核理由</td>
				<td class="nrkd lineHeight" colspan="3">{{ xjDetail.approveReason || '暂无' }}</td>
			</tr>
			<tr>
				<td class="column ">实际请假</td>
				<td class="nrkd">{{ qjDetail.actualAbsence }}小时</td>
				<td class="column">实际调休</td>
				<td class="nrkd">{{ qjDetail.actualSabbatical }}小时</td>
			</tr>
		</table>
	
		
	
	</el-dialog>
	</div>
</template>

<script setup>
import { getAbsenceList,getAbsenceDetail} from '@/api/hkd';
import useUserStore from '@/store/modules/user';
const loading = ref(true);
const detailDialogVisible = ref(false);
const tableList = ref([]);
const qjDetail = ref([]);
const auditList = ref([]);
const { proxy } = getCurrentInstance();
const { absence_type } = proxy.useDict('absence_type');
const dateRange = ref([]);
const punchStartTime =ref('');
const punchEndTime =ref('');
const workDetail = ref({})
const xjDetail = ref({});
const total = ref(0);
const data = reactive({
	queryParams: {
		pageNum: 1,
		pageSize: 10,
		name: '',
		type: 'copy'
	}
	
});
const qjzt = ref({
	1: { color: '#FA6400', lable: '待审核' },
	2: { color: '#1AC45F', lable: '通过' },
	3: { color: '#BE1A21', lable: '未通过' },
	4: { color: '#FA6400', lable: '销假待审核' },
	5: { color: '#999999', lable: '已销假' },
	6: { color: '#BE1A21', lable: '销假未通过' },
});
const { queryParams } = toRefs(data);
onMounted(() => {});

function getList() {
	loading.value = true;
	queryParams.value.startTime = dateRange.value[0]
	queryParams.value.endTime = dateRange.value[1]
	getAbsenceList(queryParams.value).then(response => {
		tableList.value = response.rows;
		total.value = response.total;
		loading.value = false;
	});
}
function reset() {
	dateRange.value = [];
	queryParams.value.name = '';
	getList();
}
function detail(absenceId){
	detailDialogVisible.value = true;
	getAbsenceDetail({ absenceId: absenceId }).then(res => {
		if (res.code == 200) {
			absence_type.value.map(item=>{
				if(item.value == res.data.absence.type){
					res.data.absence.type = item.label
					qjDetail.value = res.data.absence
				}
			})
			if(res.data.reportBack){
				 xjDetail.value  = res.data.reportBack
			}
			if(res.data.auditList){
				auditList.value = res.data.auditList
			}
		} else {
			ElMessage({
				type: 'warning',
				message: res.errmsg
			});
		}
	});
}

getList();
</script>

<style lang="scss" scoped>
.qjButtonBox {
	padding: 20px 30px;
}
.qjBut {
	background: #be1a21;
	color: #ffffff;
	width: 100px;
	text-align: center;
	border-radius: 4px;
	padding: 10px 0;
	font-size: 0.875rem;
	cursor: pointer;
}
.dialog-footer button:first-child {
	margin-right: 10px;
}
:deep(.el-form) {
	.left {
		// height: 100px;
		border-right: 2px dashed #e5e1e1;
	}
}
.userOption {
	display: flex;
	align-items: center;
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 50%;

	img {
		width: 100%;
		height: 100%;
		border-radius: 50%;
	}

	span {
		padding: 0 1rem;
	}
}
.sxm {
	margin-top: 20px;
}
.spBox,
.spBox2 {
	display: flex;
	flex-flow: column;

	p {
		margin-top: 0;
	}
	img {
		width: 45px;
		height: 45px;
		border-radius: 50%;
	}
}
.spBox2 {
	margin-right: 20px;
}
:deep(.left) {
	width: 50%;
	.el-form-item {
		display: flex;
		flex-flow: column;
	}
}
:deep(.right) {
	margin-left: 50px;
	width: 42%;
	.el-form-item {
		display: flex;
		flex-flow: column;
	}
	.spr,
	.csr {
		margin-bottom: 10px;
		.el-form-item__label {
			width: 70px !important;
		}
	}
}
.csrBox {
	margin-top: 20px;
	display: flex;
	max-height: 235px;
	overflow: auto;
	display: flex;
	flex-flow: wrap;
}
.csrBox::-webkit-scrollbar {
	display: none; /* Chrome Safari */
}
:deep( .qjTable) {
	.el-table__header-wrapper,
	.el-table__fixed-header-wrapper {
		th {
			word-break: break-word;
			background-color: #f7f7f7 !important;
			color: #515a6e;
			height: 58px !important;
			font-size: 13px;
			border: none !important;
		}
	}
	.el-table__body-wrapper {
		.el-button [class*='el-icon-'] + span {
			margin-left: 1px;
		}
		.el-table__row {
			td {
				border: none !important;
				height: 55px;
			}
		}
	}
}
.ztbox {
	display: flex;
	align-items: center;
	justify-content: center;
	.dian {
		margin-right: 8px;
		width: 7px;
		height: 7px;
		border-radius: 50%;
	}
}
.czan {
	display: flex;
	justify-content: center;
}
#printDivdyAll {
	margin-top: -23px;
	width: 1000px;
	height: 400px;
	padding: 5px;

	td {
		text-align: center;
		font-size: 18px;
	}

	.zhai {
		height: 60px;
	}

	.shense {
		font-size: 20px;
	}

	table {
		width: 100%;
		height: 100%;
	}
}
.zBox {
	height: 100%;
}
:deep(.shbj) {
	background: url(../../assets/images/spbj.png) no-repeat;
	color: #be1a21;
	width: 140px;
	background-size: 100% 100%;
	padding: 5px 15px;
	font-size: 14px;
	margin-bottom: 10px;
	font-weight: 600;
}
.sptop {
	margin-top: 20px;
}
:deep(.bz) {
	.el-form-item__label {
		width: 50px !important;
	}
}
.red {
	color: #ff0000;
}
.spzt {
	width: 20px;
	height: 20px;
	display: inline-block;
	background-size: contain;
	margin-right: 10px;
}
.jdbox {
	position: relative;
}
.jdbox:last-child .xuLine {
	display: none;
}
.xuLine {
	position: absolute;
	width: 1px;
	height: 17px;
	border-left: 2px dashed rgb(204, 204, 204);
	left: 9px;
	top: 20px;
}
.top {
	background: #ffffff;
	padding: 20px 20px 2px 20px;
	border-radius: 10px;
}
.bottom {
	padding: 20px;
	background: #ffffff;
	border-radius: 0.625rem;
	height: 87%;
	margin-top: 25px;
}
:deep( .xHeight ){
	.el-form-item__label {
		height: 40px;
		line-height: 40px;
	}
}
.pst {
	position: absolute;
	right: 36px;
	padding: 6px;
}
.ytg {
	background: url(../../assets/images/mainImg/ok.png);
	background-size:100% 100% ;
}
.dsh {
	background: url(../../assets/images/mainImg/dsh.png);
	background-size:100% 100% ;
}
.btg {
	background: url(../../assets/images/mainImg/btg.png);
	background-size:100% 100% ;
}
</style>
